package org.hhchat.leetcode.tree;

import org.hhchat.leetcode.dataStruct.TreeNode;

/**
 * https://leetcode.com/problems/same-tree/discuss/
 */
public class code100_easy {

    static class Solution {
        public boolean isSameTree(TreeNode p, TreeNode q) {
            if (p == null && q == null) {
                return true;
            }
            if (p == null || q == null) {
                return false;
            }
            if (q.val == p.val) {
                return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
            }
            return false;
        }
    }
}
